package com.xydtech.ecard.statistics.controller;

import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.statistics.domain.EcardBusiReservationRecord;
import com.xydtech.ecard.statistics.service.IEcardBusiReservationRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 预约记录Controller
 *
 * @author JHON
 * @date 2021-10-09
 */
@Controller
@RequestMapping("/statistics/reservRecord")
public class EcardBusiReservationRecordController extends BaseController {
    private String prefix = "statistics/reservRecord";

    @Autowired
    private IEcardBusiReservationRecordService ecardBusiReservationRecordService;

    @RequiresPermissions("statistics:reservRecord:view")
    @GetMapping()
    public String reservRecord() {
        return prefix + "/reservRecord";
    }

    /**
     * 查询预约记录列表
     */
    @RequiresPermissions("statistics:reservRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardBusiReservationRecord ecardBusiReservationRecord) {
        String salt = getSalt();//盐值
        startPage();
        List<EcardBusiReservationRecord> list = ecardBusiReservationRecordService.selectEcardBusiReservationRecordList(ecardBusiReservationRecord, salt);
        return getDataTable(list);
    }

    /**
     * 导出预约记录列表
     */
    @RequiresPermissions("statistics:reservRecord:export")
    @Log(title = "预约记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardBusiReservationRecord ecardBusiReservationRecord) {
        String salt = getSalt();//盐值
        List<EcardBusiReservationRecord> list = ecardBusiReservationRecordService.selectEcardBusiReservationRecordList(ecardBusiReservationRecord, salt);
        ExcelUtil<EcardBusiReservationRecord> util = new ExcelUtil<EcardBusiReservationRecord>(EcardBusiReservationRecord.class);
        return util.exportExcel(list, "reservRecord");
    }

}
